package Games.PumpGame.Gui 
{
	import flash.display.Sprite;
	import Framework.BaseGui;
	import Games.PumpGame.PumpGame;
	
	/**
	 * ...
	 * @author Menno
	 */
	public class TimerBarGui extends BaseGui
	{
		private var border:Sprite;
		private var filling:Sprite;
		private var currentTime:int = 0;
		
		public function TimerBarGui() 
		{
			border = new Sprite();
			filling = new Sprite();
			
			drawBorder();
			
			addChild(filling);
			addChild(border);			
		}
		
		private function drawBorder():void 
		{
			border.graphics.lineStyle(2, 0x00FF00);
			border.graphics.drawRect(30, PumpGame.ROOMSIZE + 45, PumpGame.ROOMSIZE, 40);
		}
		
		public function updateFilling(cycleSize:int, updateSize:int):void
		{
			if (currentTime >= cycleSize)
			{
				currentTime = 0;
			}
			
			currentTime = currentTime + updateSize;
			var length:int = (currentTime / cycleSize) * PumpGame.ROOMSIZE;
			filling.graphics.clear();
			filling.graphics.lineStyle(2, 0x00FF00);
			filling.graphics.beginFill(0x0000FF);
			filling.graphics.drawRect(30, PumpGame.ROOMSIZE + 45, length, 40);
			filling.graphics.endFill();
		}
	}
	
}